package com.gewu.pm.ui.adapter.terminal;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gewu.pm.R;
import com.gewu.pm.app.AppAdapter;

/**
 * 终端订单适配器
 */
public final class TerminalOrderAdapter extends AppAdapter<String> {

    public TerminalOrderAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ItemViewHolder();
    }

    private final class ItemViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView mOrderNoView;
        private final TextView mOrderTypeView;
        private final TextView mQuantityView;
        private final TextView mAmountView;
        private final TextView mOrderTimeView;
        private final TextView mOrdererView;
        private final TextView mStatusView;

        private ItemViewHolder() {
            super(R.layout.terminal_order_item);
            mOrderNoView = findViewById(R.id.tv_order_no);
            mOrderTypeView = findViewById(R.id.tv_order_type);
            mQuantityView = findViewById(R.id.tv_quantity);
            mAmountView = findViewById(R.id.tv_amount);
            mOrderTimeView = findViewById(R.id.tv_order_time);
            mOrdererView = findViewById(R.id.tv_orderer);
            mStatusView = findViewById(R.id.tv_status);
        }

        @Override
        public void onBindView(int position) {
            String orderNo = getItem(position);
            
            // TODO: 根据实际数据设置
            mOrderNoView.setText("SD2024032300001");
            mOrderTypeView.setText("瞿辉");
            mQuantityView.setText("1箱3包");
            mAmountView.setText("¥40.00");
            mOrderTimeView.setText("2025-8-18 19:30");
            mOrdererView.setText("陈宏伟");
            
            // 设置状态（示例）
            mStatusView.setText("已审批");
            mStatusView.setBackgroundResource(R.drawable.shape_label_green);
            mStatusView.setTextColor(getResources().getColor(R.color.green_01));
        }
    }
}

